<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/control/taglib.jsp"%>
<%@ taglib prefix="xkshow"   uri="/WEB-INF/xkshow-pages-1.0.tld"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setAttribute("ctx",basePath);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<script type="text/javascript" src="/admin/js/jquery-1.7.1.min.js"></script>
<link rel="stylesheet" href="/admin/css/demo.css" type="text/css">
	<link rel="stylesheet" href="/admin/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<script type="text/javascript" src="/admin/js/jquery.ztree.core-3.5.js"></script>
	<script type="text/javascript" src="/admin/js/jquery.ztree.excheck-3.5.js"></script>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>list</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="/admin/css/comm.css">
  </head>
  <body>
  <form action="/groupmanager!search.shtml" method="post">
    <table style="width: 100%"  id="mytable">
		<tr>
			<td colspan="4" scope="col">
				请填写查询条件
			</td>
		</tr>
		<tr>
			<td scope="col" align="center">角色名称</td>
			<td class="row">
				<input type="text"   id="name" name="entity.groupname"/>
			</td>
			<td scope="col"   align="center">角色描述</td>
			<td class="row">
				<input type="text"   id="truename" name="entity.groupinfo"/>
			</td>
		</tr>
		<tr>
			<td class="td_detail" width="20%" align="right" colSpan="4" >
				<input type="submit" value="查询">
				<input type="button" value="添加" onclick="location.href='<c:url value="/groupmanager!input.shtml"/>'">
			</td>
		</tr>
	</table>
</form>
	<br>
	<br>
	<table style="width: 100%" id="mytable" cellspacing="0">
        <tr>
            <th scope="col">角色ID</th>
            <th scope="col">角色名称</th>
            <th scope="col">角色描述</th>
          	<th scope="col">操作</th>
        </tr>
        <tbody>
		<s:iterator var="obj" value="pageList.objectList">
               <tr >
                   <td class="row">&nbsp;${obj.groupid }</td>  
                   <td class="row">&nbsp;${obj.groupname }</td>
                   <td class="row">&nbsp;${obj.groupinfo}</td>
                   <td class="row">
                   	<a href="javascript:void(0)" onclick="showDatePlanOption(this,1,${obj.groupid})" >分配权限</a>
                   	<a href="/groupmanager!input.shtml?groupid=${obj.groupid}">修改</a>
                   	<a href="##">删除</a>
                   </td>
               </tr>
            </s:iterator>
        </tbody> 
        <!--  分页显示 -->
         <tr align="center">
             <td colspan="8"><xkshow:pages value="%{pageList.pages}"/></td>
        </tr>
	</table>
  </body>
</html>
<!--**************************
 **  DatePlanOption  
 *****************************-->
<style>
#divDatePlanOption{ 
 width: 400px; height:auto; line-height:28px; vertical-align:middle;
 text-align: center;
 border: 1px solid #F9F3E2; background-color: #CCCCCC;
 position:absolute; z-index:99;  display: none;
}
#divDatePlanOption table{
	margin-top: 5px; margin-bottom: 5px;
	width: 98%;
	text-align: center;
	border: 0px; cellspacing: 1; background-color: #F1F1F1;
}
#divDatePlanOption table td{
	height: 28px;
	background-color: #FFFFFF;
}
.divDatePlanOption_btn{
	width: 98%;
	text-align: right;
}
</style>
<div id="divDatePlanOption">
    <table id="dgo_pub">
		<tr >
			<th width="20%">角色名称</th>
			<td align="left" style="padding-left: 5px;">-</td>			
		</tr>
	</table>
	<span class="divDatePlanOption_btn">
		<font id="dpo_msg" color="red"></font>
		<input type="button" onclick="addDatePlanOptionRow(this);" value="保存" class="button"/>
		<input type="button" onclick="closeDatePlanOption();" value="关闭" class="button"/>
	</span>
	<table id="dgo_data">
		<div class="zTreeDemoBackground left">
			<ul id="treeDemo" class="ztree"></ul>
		</div>
	</table>
</div>
<script type="text/javascript">
var objRowSelect=null,ajaxRes="";
var varDatePlanIsGift=0, varDatePlanGroup=0, varDatePlanVGid=0;
function clearDatePlan(){
	varDatePlanIsGift = 0;
	varDatePlanGroup = 0;
	varDatePlanVGid = 0;
	//
	$('#dgo_pub').find('td').each(function(){
		$(this).text("--");
	});
	$('#dgo_data').find('tr').each(function(i){
		if(i > 0){
			$(this).remove();
		}		
	});
}
function showDatePlanOption(obj, isGift, vgid){
	clearDatePlan();
	//$('#share_div_msg').text('接口变更中，请改日重试！');
	$('#dgo_pub').find('td').eq(0).text($(obj).parent().parent().children('td').eq(1).text());
	document.getElementById('divDatePlanOption').style.left = (document.body.offsetWidth - 540)/2; 
    document.getElementById('divDatePlanOption').style.top = (document.body.offsetHeight - 350)/2 + document.body.scrollTop;
	document.getElementById('divDatePlanOption').style.display='block';	
	//
	varDatePlanIsGift = isGift;
	varDatePlanVGid = vgid;	
	//
	var url="/groupmanager!assignInput.shtml";
	url += "?id="+varDatePlanVGid; 
	url += "&np_f_rnd="+Math.random();
	jQuery.ajax(url,{
		data: "",
		dataType: "json",
		cache: false,
		success: function(data){
			var t = $("#tree");
			//$.fn.zTree.init(t, setting, eval(data.flag));
			$.fn.zTree.init($("#treeDemo"), setting, eval(data.flag));
	    },
	    error: function(msg){
	    	alert("ERROR:系统错误!");
		}
	});
}
$(document).ready(function(){
	$("#groupAll").click(
	  function(){ 
	    if(this.checked){ 
	        $("input[name='groupDan']").attr('checked', true)
	    }else{ 
	        $("input[name='groupDan']").attr('checked', false)
	    } 
	  } 
	);
});
var setting = {
	check: {
		enable: true
	},
	data: {
		simpleData: {
			enable: true
		}
	}
};

var zNodes =[
	{ id:1, pId:0, name:"随意勾选 1", open:true},
	{ id:11, pId:1, name:"随意勾选 1-1", open:true},
	{ id:111, pId:11, name:"随意勾选 1-1-1"},
	{ id:112, pId:11, name:"随意勾选 1-1-2"},
	{ id:12, pId:1, name:"随意勾选 1-2", open:true},
	{ id:121, pId:12, name:"随意勾选 1-2-1"},
	{ id:122, pId:12, name:"随意勾选 1-2-2"},
	{ id:2, pId:0, name:"随意勾选 2", checked:true, open:true},
	{ id:21, pId:2, name:"随意勾选 2-1"},
	{ id:22, pId:2, name:"随意勾选 2-2", open:true},
	{ id:221, pId:22, name:"随意勾选 2-2-1", checked:true},
	{ id:222, pId:22, name:"随意勾选 2-2-2"},
	{ id:23, pId:2, name:"随意勾选 2-3"}
];
$(document).ready(function(){
		
});


function closeDatePlanOption(){
	document.getElementById('divDatePlanOption').style.display='none';	
}

function addDatePlanOptionRow(obj){
	var st=$(obj).html();
	var $str="";
	$("input[name='groupDan']").each(function(){
		if($(this).attr('checked')){
			$str += $(this).val() + "@checked;";
		}else{
			$str += $(this).val() + ";";
		}
	});
	var url="master!assignGroup.shtml";
	url+="?masterid="+varDatePlanVGid;
	url+="&groupidstr="+$str;
	url += "&np_f_rnd="+Math.random();
	jQuery.ajax(url,{
		data: "",
		dataType: "json",
		cache: false,
		success: function(data){
			if(data.flag=="ture")
			{
				alert("分配角色成功！");
			}
			else alert("分配角色失败！");
			closeDatePlanOption();
	    },
	    error: function(msg){
	    	alert("ERROR:系统错误!");
		}
	});
}
	
</script>